package com.intelligentclass.services;

import com.intelligentclass.entity.Courseware;
import com.intelligentclass.entity.Exercise;
import com.intelligentclass.repositories.ExerciseRespository;
import com.intelligentclass.repositories.HistorypaperRespository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExerciseService {
    private ExerciseRespository exerciseRespository;

    public ExerciseService(ExerciseRespository exerciseRespository) {
        this.exerciseRespository = exerciseRespository;
    }

    public List<Exercise> getAllExercisesByCid(int cid) {
        return exerciseRespository.findAllByCid(cid);
    }

    public Exercise getExerciseById(int id) {
        return exerciseRespository.findById(id).orElse(null);
    }
    public Exercise save(Exercise exercise) {
        return exerciseRespository.save(exercise);
    }

    public Exercise getExerciseeByCidAndName(int cid, String name){
        return exerciseRespository.findByCidAndName(cid, name);
    }

    public Exercise getExercise(int cid, String name, int parent){
        return exerciseRespository.find(cid, name, parent);
    }
}
